Support MMAP and MUNMAP system calls#945
Draft
joergroedel wants to merge 10 commits into
Draft
Conversation
| let obj: u64 = if let Some(fd) = handle { | ||
| fd.id().into() | ||
| } else { | ||
| 0u64 |
Contributor
There was a problem hiding this comment.
With None (Anonymous mapping) here 0 is assigned and it is later used in kernel/src/syscall/class0.rs:
pub fn sys_mmap(
..
let opt = obj_get(obj_id.into()).ok();
let mmap_addr = if let Some(obj) = opt {
//map with obj
}else{
//anonymous mapping
}
..
But obj_id 0 is already used in kernel/src/task/tasks.rs:
fn task_attach_console() {
let file_handle = stdout_open();
let obj_handle = ObjHandle::new(0);
current_task()
.add_obj_at(file_handle, obj_handle)
.expect("Failed to attach console");
}
So, sys_mmap finds something when looking for object 0 and it enters the wrong branch.
Workaround for testing with coconut-alloc
Changing obj_id to another value (like 1) makes the mmap work correctly when testing in the userspace allocator PR.
This in syscall/src/console.rs should be changed as well:
static CONSOLE_HANDLE: FsObjHandle = FsObjHandle::new(ObjHandle::new(0));
Add the wrappers for system calls which change the memory layout of the user-mode task. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Add conversion support for the user-mode representation of memory mapping flags to the kernel representation. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Implement methods to retrieve a reference to the FileHandle or DirectoryHandle the object points to. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Implement the system call to allow user-mode applications to change their memory layout. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Implement the system call to unmap memory mappings from the virtual address space. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
These two methods can be implemented for trait VirtualMapping to support resizing of an existing mapping. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Convert the map_vmm() and unma_vmm() methods to the more generic map/unmap_range() methods which can handle sub-ranges of VMMs as well. Re-implement map/unmap_vmm() to use the more generic methods. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Move the TLB flush logic to a helper function to re-use it at other places. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Add a method to struct VMR to resize an existing mapping. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Support the resizing of VMalloc mappings. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the MMAP and MUNMAP system calls and foundations for MRESIZE. The system calls do not have Posix semantics yet. In fact, partial unmaps are not supported. A
VMMcan only be unmapped as a whole for now.The foundations for MRESIZE are also implemented, but that support is not finished yet. Therefore this PR is marked as Draft.